package cn.javastudy.design._3_行为型模式._解释器模式;

import lombok.AllArgsConstructor;

/**
 * 非终结符表达式  加法表达式
 *
 * @author sumou
 * @date 2025/01/25
 */
@AllArgsConstructor
public class Plus extends AbstractExpression {

    private AbstractExpression left;
    private AbstractExpression right;

    @Override
    public int interpret(Context context) {
        return left.interpret(context) + right.interpret(context);
    }

    @Override
    public String toString() {
        return "(" + left.toString() + " + " + right.toString() + ")";
    }

}
